# Maintainer: Masanori Shirayama <mashir43@gmail.com>

pkgname=mksh
_ver=51
# use a pacman compatible version scheme
pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}}
pkgrel=1
pkgdesc="The MirBSD Korn Shell"
arch=("i686" "x86_64")
url="http://www.mirbsd.org/mksh.htm"
license=('ISC')
depends=('gcc-libs')
makedepends=('gcc')
provides=('ksh')
conflicts=('ksh')
install=mksh.install
source=("https://www.mirbsd.org/MirOS/dist/mir/$pkgname/$pkgname-R${_ver}.tgz"
        "http://www.mirbsd.org/TaC-mksh.txt")
md5sums=('8e522475da795c60f35a6f8035481baf'
         '56add717e01667833e5c8148afddabb6')

build() {
  cd "${srcdir}/$pkgname"

  ./Build.sh
}

check() {
  cd "${srcdir}/$pkgname"
  ./test.sh
}

package() {
  cd "${srcdir}/$pkgname"

  mkdir -p "$pkgdir/usr/bin"
  mkdir -p "$pkgdir/usr/share/man/man1"
  mkdir -p "$pkgdir/usr/share/licenses/mksh"

  cp -f mksh.exe $pkgdir/usr/bin
  cp -f mksh.1 $pkgdir/usr/share/man/man1

  cd "${srcdir}"
  cp -f TaC-mksh.txt $pkgdir/usr/share/licenses/mksh

  cd "$pkgdir/usr/bin"
  cp -f mksh.exe ksh.exe
}
